package edu.sctu.zhoudie.mouth201505.day20150524.TextThree;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by user08 on 2015/5/24.
 */
public class Deal {


    public List dealling(Student[] stu) {

        DataCourse datas = new DataCourse();
        List list = new ArrayList<>();
        List list1 = new ArrayList<>();
        List list2 = new ArrayList<>();
        List list3 = new ArrayList<>();

        list1.add(datas.courses[0]);
        list2.add(datas.courses[1]);
        list3.add(datas.courses[2]);

        for (int i = 0; i < stu.length; i++) {
            for (int j = 0; j < stu[i].dataCourse.length; j++) {

                if (datas.courses[0].equals(stu[i].dataCourse[j])) {
                    list1.add(stu[i]);
                }
                if (datas.courses[1].equals(stu[i].dataCourse[j])) {
                    list2.add(stu[i]);
                }
                if (datas.courses[2].equals(stu[i].dataCourse[j])) {
                    list3.add(stu[i]);
                }
            }
        }

        int max;
        max = Math.max(Math.max(list1.size(), list2.size()), list3.size());
        if (max == list1.size()) {
            list = list1;
        }
        if (max == list2.size()) {
            list = list2;
        }
        if (max == list3.size()) {
            list = list3;
        }

        return list;

    }
}
